using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Hostal.Bussines.Entities;

namespace Hostal.Bussines.Repository.Mapping
{
    public class DetalleReservaMap : EntityTypeConfiguration<DetalleReserva>
    {
        public DetalleReservaMap()
        {
            // Primary Key
            this.HasKey(t => new { t.IdHabitacion, t.IdReserva });

            // Properties
            this.Property(t => t.IdHabitacion)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.IdReserva)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("DetalleReserva");
            this.Property(t => t.IdHabitacion).HasColumnName("IdHabitacion");
            this.Property(t => t.IdReserva).HasColumnName("IdReserva");
            this.Property(t => t.numero).HasColumnName("numero");
            this.Property(t => t.monto).HasColumnName("monto");

            // Relationships
            this.HasRequired(t => t.Habitacion)
                .WithMany(t => t.DetalleReservas)
                .HasForeignKey(d => d.IdHabitacion);
            this.HasRequired(t => t.Reserva)
                .WithMany(t => t.DetalleReservas)
                .HasForeignKey(d => d.IdReserva);

        }
    }
}
